<?php
    use User\Model\LpicModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        <a href="/User/Lpic/index">直播列表</a>->图集列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="<?php echo '/User/Lpic/picUpdate?liveId=' . I('get.id', '', '');?>">增加</a>

                <form class="" role="form" >
                    <input type="hidden" name="id" value="<?php echo I('get.id', '', '');?>">
                    <div class="container">
                        <div class="row">
                            <div class="form-group col-lg-1"></div>
                            <div class="form-group col-lg-3">
                                <div class="input-group">
                                    <span class="input-group-addon">开始时间</span>
                                    <input class="form-control" id="date-picker1" name="start_date" value="<?php
                                    echo I('get.start_date', '', '');
                                    ?>" >
                                </div>
                            </div>
                            <div class="form-group col-lg-1"></div>
                            <div class="form-group col-lg-3">
                                <div class="input-group">
                                    <span class="input-group-addon">结束时间</span>
                                    <input class="form-control" id="date-picker2" name="end_date" value="<?php
                                    echo I('get.end_date', '', '');
                                    ?>" >
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group col-lg-1"></div>
                            <div class="form-group col-lg-3">
                                <div class="input-group">
                                    <span class="input-group-addon">作者</span>
                                    <input type="text" name="author" class="form-control" value="<?php
                                    echo I('get.author', '', '');
                                    ?>">
                                </div>
                            </div>
                            <div class="form-group col-lg-1"></div>
                            <div class="form-group col-lg-3">
                                <div class="input-group">
                                    <span class="input-group-addon">昵称</span>
                                    <input type="text" name="nickname" class="form-control" value="<?php
                                    echo I('get.nickname', '', '');
                                    ?>">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="form-group col-lg-1"></div>
                            <div class="form-group col-lg-3">
                                <div class="input-group">
                                    <span class="input-group-addon">专题</span>
                                    <select class="form-control" name="item_id" >
                                        <?php
                                    echo "<option value='-1' ";
                                    if(I("get.item_id", "", "") == "-1"){
                                        echo " selected";
                                    }
                                    echo ">--全部--</option>";
                                            foreach($pic_item_list as $k => $pic_item){
                                                echo "<option value='" . $k . "'";
                                                if($k == I("get.item_id", "", "")){
                                                    echo " selected";
                                                }
                                                echo ">" . $pic_item . "</option>";
                                            }
                                        ?>

                                    </select>
                                </div>
                            </div>
                            <div class="form-group col-lg-2"></div>
                            <input class="btn btn-success" type="submit" value="筛选">
                            <button class="btn btn-default" onclick="return empty_cond();">清空</button>
                        </div>
                    </div>
                </form>


            </header>
            <div class="panel-body">
                <input type="hidden" value="<?php echo I('get.id', '', '');?>" id="liveId">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="15%">图片</th>
                        <th width="10%">作者</th>
                        <th width="10%">昵称</th>
                        <th width="15%">专题</th>
                        <th width="12%">创建时间</th>
                        <th width="10%">状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <img src="<?php echo $val['pic_url']?>" alt="" width="100px;">
                            </span>
                        </td>
                        <td>
                            <span >
                                <?php
                                echo $val['author'];
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['nickname'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-break:break-all;word-wrap:break-word;">
                                <?php
                                $name = '';
                                if(!empty($val['item_id']) && array_key_exists($val['item_id'], $pic_item_list)){
                                    $name = $pic_item_list[$val['item_id']];
                                }
                                echo $name;
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['added_date'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo LpicModel::getStatus($val['status']);?>
                            </span>
                        </td>
                        <td>
                            <div>
                                <a class="btn btn-success"
                                   href="<?php echo '/User/Lpic/picUpdate?type=update&liveId=' . $val['live_id'] . '&picId=' . $val['pic_id'];?>">编辑</a>
                                <a class="btn btn-danger" href="#"
                                   onclick="<?php echo 'return delete_data(' . $val['pic_id'] .')';?>">删除</a>
                            </div>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{picId:id},
            dataType:'json',
            url:'/User/Lpic/picDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function empty_cond(){
        var id = $("#id").val();
        window.location = "/User/Lpic/pic?id=" + id;
    }
</script>
<script type="text/javascript" src="/Public/js/laydatenew/laydate.js"></script>
<script type="text/javascript">
    laydate.render({
        elem: '#date-picker1',
        type: 'datetime'
    });
    laydate.render({
        elem: '#date-picker2',
        type: 'datetime'
    });
</script>